import { Module } from "@nestjs/common";
import { AppController } from "./app.controller";
// 引入服务
import { AppService } from "./app.service";
import {
  LoggerService,
  UseClassLoggerService,
  UseValueLoggerService,
  UseFactoryLoggerService,
} from "./logger.service";
import { FetchData } from "./fecthData.service";

@Module({
  controllers: [AppController],
  // 声明依赖, 控制器就可以直接拿到实例, 容器自动创建Service实例
  providers: [
    AppService,
    FetchData,
    LoggerService,
    {
      provide: UseClassLoggerService,
      useClass: UseClassLoggerService,
    },
    {
      provide: UseValueLoggerService,
      useValue: new UseValueLoggerService(),
    },
    {
      provide: UseFactoryLoggerService,
      useFactory: () => new UseFactoryLoggerService(),
    },
  ],
})
export class AppModule {}
